package com.llgz.hotelmanageapi.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author Bernie_fang
 * @Description:
 * @create 2021/7/19 12:53
 **/
@Component
public class MyBatisDateConfig implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createdTime",new Date(),metaObject);
        this.setFieldValByName("modifiedTime",new Date(),metaObject);
        this.setFieldValByName("deleted",false,metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("modifiedTime", new Date(), metaObject);
    }
}
